package org.oy.sealogger.device;

import java.io.InputStream;

import org.oy.sealogger.ds.InputAnalyser;

/**
 * All devices should implement this interface
 * @author riku
 *
 */
public interface Device {

	/**
	 * Open connection with a device
	 * @param InputAnalyser object to analyse the input stream
	 * @return InputStream object related to the device
	 * @throws DeviceException
	 */
	public void connect() throws DeviceException;
	
	/**
	 * Get the device input stream
	 * @return InputStream object
	 */
	public InputStream getInputStream();
	
	/**
	 * Close connection with a device
	 * @throws DeviceException
	 */
	public void disconnect() throws DeviceException;
	
	/**
	 * Tests if the device has been connected
	 * @return true if the device is connected, otherwise false
	 */
	public boolean isConnected();
	
	/**
	 * Tells if the device has produced data to read
	 * @return
	 */
	public boolean dataAvailable();

	/**
	 * Tests if connection can be established to the device
	 * @return true or false
	 */
	public boolean test();
	
	/**
	 * Sets an analyser for verifying data from the device
	 * @param analyser
	 */
	public void setInputAnalyser(InputAnalyser analyser);
	
	/**
	 * Return a descriptive, human readable name for the device
	 * @return
	 */
	public String getDeviceName();
}
